package think.in.java.concurrency.practise.exec6;

import java.util.concurrent.locks.ReentrantLock;

/**
 * Created by IntelliJ IDEA.
 * User: Richard
 * Date: 6/12/11
 * Time: 5:49 PM
 * In this class , there will instance four objects for different sync mechanism
 */
public class ThreadTester {
    public static void main(String[] args) {
        System.out.println("there is the test for different sync!!! if the number is less mean it failed fast !!");
        System.out.println("=====EvenGeneratorForSync=====");
        //never fail
        EvenChecker.test(new EvenGeneratorForSync());
        try {
            //fail slower
            Thread.sleep(2000);
            System.out.println("=====EvenGeneratorForVolatile=====");
            EvenChecker.test(new EvenGeneratorForVolatile());
            //failed faster
            Thread.sleep(2000);
            System.out.println("=====EvenGeneratorForAtom=====");
            EvenChecker.test(new EvenGeneratorForAtom());
            //never failed
            Thread.sleep(2000);
            System.out.println("=====EvenGeneratorForLock=====");
            EvenChecker.test(new EvenGeneratorForLock());
        } catch (InterruptedException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }


    }
}
